PixelationSettings.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using System;
  2. using ExternPropertyAttributes;
  3. using UnityEngine;
  4. using UnityEngine.Rendering.Universal;
  5. // ReSharper disable RedundantDefaultMemberInitializer
  6. namespace FlatKit {
  7. [CreateAssetMenu(fileName = "PixelationSettings", menuName = "FlatKit/Pixelation Settings")]
  8. public class PixelationSettings : ScriptableObject {
  9. [Space] // Expandable.
  10. #if !UNITY_2022_3_OR_NEWER
  11. [ExternPropertyAttributes.InfoBox(
  12. "Pixelation Effect requires Unity 2022.3 or newer. Please upgrade your Unity version to use this feature.",
  13. ExternPropertyAttributes.EInfoBoxType.Warning)]
  14. [Space]
  15. #endif
  16. [Tooltip("The number of pixels on the longer side of the screen.\nLower values result in a more pixelated image.")]
  17. [Min(0)]
  18. public int resolution = 320;
  19. [HorizontalLine(1, EColor.Translucent)]
  20. [Tooltip("The render stage at which the effect is applied. To exclude transparent objects, like water or " +
  21. "UI elements, set this to \"Before Transparent\".")]
  22. public RenderPassEvent renderEvent = RenderPassEvent.BeforeRenderingPostProcessing;
  23. [Tooltip("Whether the effect should be applied in the Scene view as well as in the Game view. Please keep in " +
  24. "mind that Unity always renders the scene view with the default Renderer settings of the URP config.")]
  25. public bool applyInSceneView = true;
  26. [HideInInspector]
  27. public Material effectMaterial;
  28. internal Action onSettingsChanged;
  29. internal Action onReset;
  30. private void OnValidate() {
  31. onSettingsChanged?.Invoke();
  32. }
  33. private void Reset() {
  34. onReset?.Invoke();
  35. }
  36. private void OnDestroy() {
  37. onSettingsChanged = null;
  38. onReset = null;
  39. }
  40. }
  41. }